1. Field of the Invention
The present invention relates to "pointer-safe" computer programming languages, which prevent arbitrary references through pointers. More specifically, the present invention relates to a method and an apparatus for supporting efficient systems programming within a dynamic, pointer-safe programming language.
2. Related Art
Object-oriented programming languages with automatic memory management, such as the JAVA.TM. programming language of Sun Microsystems, Inc. of Palo Alto, Calif., are widely recognized for making software development easier. Unlike conventional programming languages such as C or C++ that require programmers to use pointers and explicit memory allocation operations to manage dynamic data structures, languages such as the Java programming language take care of memory management automatically. This eliminates the need for tedious and error-prone pointer manipulation. Languages such as the Java programming language are sometimes referred to as "pointer-safe" languages, because they largely eliminate errors that can arise during pointer manipulation. Pointer-safe programming languages are generally languages that do not allow programmers to manipulate pointers outside of the context of, or in violation of, a type system.
Sun, the Sun logo, Sun Microsystems, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.
Another important characteristic of the Java programming language is the dynamic nature of the language. Unlike C or C++, in which the source program is compiled directly into native, platform-specific machine code, a Java program is executed in an interpretive fashion. This allows programs to be extended dynamically at runtime, and makes them highly portable across different computing devices and platforms.
However, while dynamic, pointer-safe languages excel at making software development faster and less error-prone by relieving the programmer of the burden of explicitly allocating memory and manipulating pointers, they are not commonly used for "systems programming." In systems programming, a programmer needs more explicit control of object allocation and deallocation in order to more efficiently map data structures onto low-level, machine-dependent structures, and to better manage performance issues related to memory management.
Programmers have traditionally recognized a trade-off between good programming style on one hand and control over memory management on the other. Programming languages with automatic memory management relieve the programmer of the responsibility of explicit memory management, and this generally leads to better programming style. However, at the same time these languages provide less control over memory allocation and pointer manipulation during execution, thus making the behavior of the program harder to understand. While languages with automatic memory management often provide reasonable performance in typical application programming tasks, in certain "systems programming" tasks (such as implementing efficient virtual machines for new programming languages or for real-time applications) the reduced control over memory management can cause performance problems, especially when implementing the system using a dynamic programming language.
Presently, programmers typically do not use dynamic programming languages with automatic memory management for systems programming tasks, but instead write systems programs using other, less elegant programming languages such as C or C++.
What is needed is a mechanism that allows efficient, systems programming tasks to be implemented in a higher-level, dynamic, pointer-safe language such as the Java programming language.